<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	
</body>
</html>
<script>
	//随机数
	//Math.random（）返回一个[0,1)的随机数
	var num = Math.random();
	document.write(num);

    //随机数[0,10)的数
	num = Math.random()*10;
	document.write("<br>");
	//保留两位小数
	//document.write(num.toFixed(2));

	//向下取整
	num = Math.floor(Math.random() * 10);
	document.write(num);
     document.write("<br>");
	//随机5到10
	num = Math.floor(Math.random() * 10 + 5);
	document.write(num);


	//[15,20]
	//[0,5] + 15
	num = Math.floor(Math.random() * 6 + 15);
	document.write(num);

	//[26,45]
	//[0,19] + 26
	//num = Math.floor(Math.random() * 20 + 26;
	document.write(num);


	//[m,n]
	var m = 27, n = 46;
	num = Math.floor(Math.random() * n-m+1 + n);
	document.write(num);

	document.write("<hr>");

	//随机十个[20,40]的随机数，放到数组中，并求他们的和，最大数，最小数，平均数
	 var sum= 0;
	 var arr = [];
	 var min = 40;
	 var max = 20;
	 for (var i = 0; i <=10;i++);{
	 var num = Math.floor(Math.random() * 21 + 20);
	 	  arr[i] = num;
	 	  sum += num;
	 	  min = min < num ? min : num;
	 	  max = max > num ? max :num; 
	 }
	 document.write("sum" + sum);






</script>